package com.bjbn.controller;

import com.bjbn.bean.ApiCallParams;
import com.bjbn.bean.ApiResult;
import com.bjbn.service.DataphinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
@Slf4j
public class IndexController {

    @Autowired
    DataphinService dataphinService;

    @RequestMapping("/hello")
    public String index() {
        return "Hello World!";
    }

    @RequestMapping("/test")
    public ApiResult test() {
        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10353");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields("id,flightid,craftsite,starttime,endtime,startrealtime,endrealtime,ordercode");
        apiCallParams.setListType("LIST");
        apiCallParams.setPageStart(1);
        apiCallParams.setPageSize(10);

        return dataphinService.getDataphinData(apiCallParams);
    }
}
